<?php
namespace app\admin\model;

class Goods extends BaseModel
{
    protected $table = 'cz_goods';
    protected $rule = [
        'uid'  =>  '',
    ];
    protected $msg = [
        'uid'  =>  '',
    ];
    protected $return = array();
    //列表
    //  wxy
    public function getList(){
        $list = $this->order("good_id asc")->paginate("10");
        return $list;
    }
    //添加修改
    //  wxy
    public function goodsEdit(){
        $goods_name = input("post.goods_name");
        $price = input("post.price");
        $id = input("post.good_id");
        $data = input("post.");

        $where ['good_id'] = $id;
        if(!empty($id) && $id != 0){
            $res = $this->save($data,$where);
        }else{
            $res = $this->insert($data);
        }
        if($res){
            return $status = [
                'code' => 1,
                'msg' => '操作成功'
            ];
        }else{
            return $status = [
                'code' => 0,
                'msg' => '操作失败'
            ];
        }
    }
    //删除商品
    //  wxy
    public function goodsDel($id){
        $res = $this->where("good_id = ".$id)->delete();
        if($res){
            $this->return ['status'] = 1;
            $this->return ['msg'] = "删除成功";
        }else{
            $this->return ['status'] = 0;
            $this->return ['msg'] = "删除失败";
        }
        return $this->return;
    }
}
?>